package com.tz.shop.seckill.configer;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 铁铸
 * @create 2021-07-17 0:37
 */
/**
 * 秒杀相关的交换机和队列绑定的创建
 */
@Configuration
public class SecKillMQ {

    @Bean("setExchange")
    public Exchange setExchange(){
        return ExchangeBuilder.topicExchange("seckill_exchange").build();
    }

    @Bean("setQueue")
    public Queue setQueue(){
        return QueueBuilder.durable("seckill_queue").build();
    }

    @Bean("setBind")
    public Binding setBind(@Qualifier("setExchange") Exchange setExchange,
                           @Qualifier("setQueue") Queue setQueue){
        return BindingBuilder.bind(setQueue).to(setExchange).with("seckill.#").noargs();
    }
}
